<?php
namespace app\tools\controller;
use app\tools\logic\ApiLogic;
use app\tools\logic\ChannelCountryLogic;

class ChannelCountry extends Base{
	//国家绑定到洲
	function toContinent(){
		$rs = ChannelCountryLogic::toContinent();
		return ApiLogic::return($rs);
	}

	//获取列表
	function getList(){
		$data = ChannelCountryLogic::getList();
		return ApiLogic::return(0,'',$data);
	}
	//获取详情
	function getInfo(){
		$info = ChannelCountryLogic::getInfo();
		return ApiLogic::return(0,'',$info);
	}
	//保存
	function save(){
		$rs = ChannelCountryLogic::save();
		if($rs){
			return ApiLogic::return($rs);
		}else{
			return ApiLogic::return(0);
		}
	}
	//新增
	function add(){
		$rs = ChannelCountryLogic::add();
		if($rs){
			return ApiLogic::return($rs);
		}else{
			return ApiLogic::return(0);
		}
	}

	//删除
	function delete(){
		$rs = ChannelCountryLogic::delete();
		if($rs){
			return ApiLogic::return($rs);
		}else{
			return ApiLogic::return(0);
		}
	}
	//批量导入
	function addList(){
		$rs = ChannelCountryLogic::addList();
		if($rs['code']!=0){
			return ApiLogic::return($rs['code']);
		}else{
			$msg = "";
			if($rs['cf']>0){
				$msg .= "缺少国家名或者国家代号".$rs['cf'].'个已忽略 ';
			}
			if($rs['cg']>0){
				$msg .=" 成功导入/修改国家".$rs['cg'].'个';
			}
			return ApiLogic::return(0,$msg);
		}
	}

	function server(){
		$rs = ChannelCountryLogic::server();
		if($rs['code']==0){
			return ApiLogic::return(0,'',$rs['data']);
		}else{
			return ApiLogic::return($rs['code']);
		}
	}

	//服务绑定到国家
	function serverToCountry(){
		$rs = ChannelCountryLogic::serverToCountry();
		if($rs){
			return ApiLogic::return($rs);
		}else{
			return ApiLogic::return(0);
		}
	}

	function saveServer(){
		$rs = ChannelCountryLogic::saveServer();
		return ApiLogic::return($rs);
	}

}
